var express = require('express');
var router = express.Router();

/* GET logins listing. */
router.get('/', function(req, res, next) {
  res.render('login',{});
});
router.post('/',function(req,res,next){
	var namenow = req.body.username;
	// var pwdnow = req.body.pwd;
	console.log(namenow);
	 console.log(namenow[0]);
	if (namenow[0]!=''&&namenow[1]!='') {
	 req.users.find({username:namenow[0],pwd:namenow[1]}).forEach(function(doc){
                if(doc==''){
                  	   console.log("error")
                  }else{
                  	 res.redirect('..');
                  };
	   });
	};
      });    
module.exports = router;
